﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;

public class ServerManager : UnitySingleton<ServerManager>
{
    private Dictionary<SERVER_TYPE, BaseServer> serverDic;
    private List<BaseServer> servers;

    private BaseServer timeServer;
    //private BaseServer luaServer;

    public override void Init()
    {
        servers = new List<BaseServer>();
        serverDic = new Dictionary<SERVER_TYPE, BaseServer>();
        timeServer = new TimeServer();
        //luaServer = new LuaServer();

        serverDic.Add(SERVER_TYPE.TIME_SERVER, timeServer);
        servers.Add(timeServer);
    }

    public BaseServer GetServer(SERVER_TYPE serverType)
    {
        if (serverDic.ContainsKey(serverType))
        {
            return serverDic[serverType];
        }
        return null;
    }

    private void Update()
    {
        if(servers != null)
        {
            for (int i = 0; i < servers.Count; i++)
            {
                BaseServer server = servers[i];
                server.OnUpdate();
            }
        }
    }
}
